package light.head.model.inv;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import light.head.framework.entity.ExcelField;

import org.hibernate.annotations.Formula;

/**
 * 零售单明细
 * @author yy
 *
 */
@Entity
@Table
public class InvSaleInfoItem implements Serializable {

	private static final long serialVersionUID = 6656041798879027942L;
	
	private Integer code;
	private Integer cc;						// 商品编号
	private Integer isc;					// 零售单编号
	@ExcelField(order = 2, name = "零售单价")
	private Double price;					// 零售单价
	@ExcelField(order = 3, name = "数量")
	private Integer count;					// 数量
	private Boolean deleted = false;		// 是否删除
	private Byte snc;						// 序列号状态 (1.没有序列号 2.一类序列号 3.唯一序列号)注意：这里是从入库单那里得来的
	@ExcelField(order = 5, name = "序列号")
	private String setsnc;
	@ExcelField(order = 7, name = "备注")
	private String remark;					// 备注
	@ExcelField(order = 1, name = "商品名称")
	private String cname;					// 商品名称
	private List<InvSaleInfoDetail> detailList;
	@ExcelField(order = 6, name = "时间")
	private Date time;
	@ExcelField(order = 4, name = "单位")
	private String un;					// 单位
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Byte getSnc() {
		return snc;
	}
	@Column
	public Integer getCc() {
		return cc;
	}
	@Column
	public Integer getIsc() {
		return isc;
	}

	@Column
	public Double getPrice() {
		return price;
	}
	@Column
	public Integer getCount() {
		return count;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Column
	public String getRemark() {
		return remark;
	}
	@Formula("(SELECT c.name FROM InvCommodityInfo c WHERE c.code IN (SELECT ci.cc FROM InvCommodityItem ci WHERE ci.code = cc))")
	public String getCname() {
		return cname;
	}
	@Formula("(SELECT isi.ct FROM InvSaleInfo isi WHERE isi.code = isc)")
	public Date getTime() {
		return time;
	}
	@Transient
	public List<InvSaleInfoDetail> getDetailList() {
		return detailList;
	}
	@Transient
	public String getSetsnc() {
		return setsnc;
	}
	@Formula("(SELECT c.name FROM InvUnit c WHERE c.code IN (SELECT ci.uc FROM InvCommodityItem ci WHERE ci.code = cc))")
	public String getUn() {
		return un;
	}
	

	
	
	
	public void setUn(String un) {
		this.un = un;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public void setSetsnc(String setsnc) {
		this.setsnc = setsnc;
	}
	public void setCname(String cname) {
		this.cname = cname;
	}
	public void setDetailList(List<InvSaleInfoDetail> detailList) {
		this.detailList = detailList;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setCc(Integer cc) {
		this.cc = cc;
	}
	public void setIsc(Integer isc) {
		this.isc = isc;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	public void setCount(Integer count) {
		this.count = count;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setSnc(Byte snc) {
		if (null != snc && snc == 1){
			this.setSetsnc("没有序列号");
		}else if(null != snc && snc == 2) {
			this.setSetsnc("一类序列号 ");
		}else if(null != snc && snc == 3){
			this.setSetsnc("唯一序列号");
		}
		this.snc = snc;
	}

	
	
}
